@echo off
chcp 65001
echo ===============================================
echo 若依校园防欺凌系统 - 恢复正确密码并重启
echo ===============================================

echo.
echo 1. 停止现有Java进程...
taskkill /f /im java.exe >nul 2>&1
timeout /t 2 >nul

echo 2. 恢复正确的admin密码...
echo 正在连接MySQL执行SQL脚本...
for %%i in ("C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe" "C:\mysql\bin\mysql.exe" "mysql") do (
    if exist "%%~i" (
        echo 找到MySQL: %%~i
        "%%~i" -u root -pwjrwjrwjr666 < "恢复正确密码.sql"
        if !errorlevel! equ 0 (
            echo ✓ 密码恢复成功
            goto restart_app
        ) else (
            echo ✗ 密码恢复失败
        )
    )
)

echo 如果MySQL命令失败，请手动执行恢复正确密码.sql文件

:restart_app
echo.
echo 3. 重新启动应用...
cd ruoyi-admin\target
echo 正在启动若依后台管理系统...
start java -jar ruoyi-admin.jar

echo.
echo ===============================================
echo 应用已启动，请稍等30秒后访问：
echo http://localhost:8089
echo 用户名: admin
echo 密码: admin123
echo ===============================================
pause 